class Solution(object):
    def canCompleteCircuit(self, gas, cost):
        """
        :type gas: List[int]
        :type cost: List[int]
        :rtype: int
        """
        #暴力破解
        l = len(gas)
        total_gas = 0
        cur_gas = 0
        start = 0
        
        for s in range(l):
            res = gas[s] - cost[s]
            cur_gas += res
            total_gas += res
            if cur_gas < 0:
                start = s + 1
                cur_gas = 0
        if total_gas < 0:
            return -1
        return start

